package com.itheima.jobs;

import com.itheima.utils.QiniuUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import redis.clients.jedis.Jedis;
import redis.clients.jedis.JedisPool;

import java.util.Set;
@Component
public class JobDemo {
    @Autowired
    private JedisPool jedisPool;

    public void clear() {

        Jedis jedis = null;
        try {
            jedis = jedisPool.getResource();
            Set<String> sdiff = jedis.sdiff("allPicture","usePicture");
            for (String s : sdiff) {
                QiniuUtils.deleteFileFromQiniu(s);
                jedis.srem("allPicture",s);
            }
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            if (jedis != null) {
                jedis.close();
            }
        }
    }
}
